package com.ybkj.daijia.serverUtils;

import com.ybkj.daijia.ServiceSetting;
import java.util.Properties;
import org.springframework.core.io.support.PropertiesLoaderUtils;

public class ServiceUtil {

    private static ServiceSetting serviceSetting = getServiceSetting();

    public static ServiceSetting checkOpen() {
        return serviceSetting;
    }

    private static ServiceSetting getServiceSetting() {

        ServiceSetting serviceSetting = new ServiceSetting();
        try {
            Properties prop = PropertiesLoaderUtils.loadAllProperties("config.properties");
            String daijia = prop.getProperty("function.daijia.open");
            String zhuanche = prop.getProperty("function.zhuanche.open");
            String gasstation = prop.getProperty("function.gasstation.open");
            String zuche = prop.getProperty("function.zuche.open");
            String paotui = prop.getProperty("function.paotui.open");
            String freight = prop.getProperty("function.freight.open");
            String zhuanxian = prop.getProperty("function.zhuanxian.open");
            String partner = prop.getProperty("function.partner.open");
            String zhifu = prop.getProperty("function.zhifu.open");
            String jgpt = prop.getProperty("function.jgpt.open");
            String randomRedPacket = prop.getProperty("function.randomRedPacket.open");
            String redPacketCycle = prop.getProperty("function.randomRedPacket.lifeCycle");
            String redPacketMoney = prop.getProperty("function.randomRedPacket.money");

            serviceSetting.setDaijia(Boolean.valueOf(daijia));
            serviceSetting.setZhuanche(Boolean.valueOf(zhuanche));
            serviceSetting.setZuche(Boolean.valueOf(zuche));
            serviceSetting.setPaotui(Boolean.valueOf(paotui));
            serviceSetting.setFreight(Boolean.valueOf(freight));
            serviceSetting.setZhuanxian(Boolean.valueOf(zhuanxian));
            serviceSetting.setPartner(Boolean.valueOf(partner));
            serviceSetting.setZhifu(Boolean.valueOf(zhifu));
            serviceSetting.setGasstation(Boolean.valueOf(gasstation));
            serviceSetting.setJgpt(Boolean.valueOf(jgpt));
            serviceSetting.setRandomRedPacket(Boolean.valueOf(randomRedPacket));
            serviceSetting.setRedPacketCycle(redPacketCycle);
            serviceSetting.setRedPacketMoney(Double.valueOf(redPacketMoney));

        } catch (Exception e) {
            e.printStackTrace();
        }

        return serviceSetting;
    }
}
